package com.example.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class product {
    final String key ="myconfig";
    final String value="this is my config";
    @Autowired
    RedisTemplate redisTemplate;
    @GetMapping("/product")
    public String product() {
        Boolean flag = redisTemplate.opsForValue().setIfAbsent(key, value);
        if (!flag){
            return "生产失败";
        }

        return "生产成功";
    }
}
